package com.banshuibao.bsb_android.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.model.UnAnswerModel;
import com.banshuibao.bsb_android.util.TimeUtil;

public class AlreadyDetailsActivity extends BaseActivity {

    private TextView content;
    private TextView date;
    private TextView answer;
    private TextView answer_date;
    private View view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_already_details);
        initView();
        getData();
    }

    private void getData() {
        UnAnswerModel.DataBean item = (UnAnswerModel.DataBean) getIntent().getSerializableExtra("item");
        if (item != null) {
            String content1 = item.getContent();
            long createDate = item.getCreateDate();
            String answer1 = item.getAnswer();
            long ansDate = item.getAnsDate();
            if (!TextUtils.isEmpty(content1)){
                content.setText(content1);
            }
            if (!TextUtils.isEmpty(answer1)){
                answer.setText(answer1);
            }else{
                answer.setVisibility(View.GONE);
            }
            String time = null;
            if (createDate != 0) {
                time = TimeUtil.format(createDate);
            } else {
                time = "";
            }
            date.setText(time);
            String time1 = null;
            if (ansDate != 0) {
                time1 = TimeUtil.format(ansDate);
            } else {
                time1 = "";
                answer_date.setVisibility(View.GONE);
                view.setVisibility(View.GONE);
            }
            answer_date.setText(time1);
        }
    }

    private void initView() {
        setTitleText("回答详情");
        content = (TextView) findViewById(R.id.content);
        date = (TextView) findViewById(R.id.date);
        answer = (TextView) findViewById(R.id.answer);
        answer_date = (TextView) findViewById(R.id.answer_date);
        view = findViewById(R.id.view_four);
    }
}
